package com.ruoyi.tasks.QRTest;
 
import com.ruoyi.tasks.util.QRCodeUtil;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
 
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
 
/**
 * FileName: creatErWeiCode2
 * Author:   xuan zongjun
 * Date:     2022/6/15 11:09
 * Description: java 生成二维码
 */
 
@RunWith(SpringRunner.class)
@SpringBootTest
public class creatErWeiCode2 {
 
    @Test
    public void createQrCode(){
        String content="http://www.zhuangyuan123.com/detail/1536622372243771392.html";
 
        BufferedImage image = QRCodeUtil.createImage( "utf-8", content, 360, 360 );
 
         //QRCodeUtil.textToImage( "扫码获取答案", 100, 100, 10 );
 
        QRCodeUtil.addUpFont( image,"扫码完成核酸" );
 
        String formatName="png";
        String imagePath="F:\\IntelliJIDEA\\projects\\RuoYi-Cloud\\ruoyi-ui\\src\\assets\\images\\code.png";
        try {
            ImageIO.write(image, formatName, new File(imagePath));
        } catch (IOException e) {
            e.printStackTrace();
        }
        System.out.println("执行完成");
 
    }
 
}